<%- include('common/head_back.ejs') %>
<%- include('common/body_back.ejs') %>
<%- include('common/head_nav_back.ejs') %>

<table class="table table-hover" style="width: 100%;">
    <caption>商品信息列表</caption>
    <thead>
    <tr>
        <th class="col-sm-1">编号</th>
        <th class="col-sm-5">商品名称</th>
        <th class="col-sm-1">商品价格</th>
        <th class="col-sm-2">创建时间</th>
        <th class="col-sm-2">修改时间</th>
        <th class="col-sm-1">商品操作</th>
    </tr>
    </thead>
    <tbody>
    <% goods.forEach(function(item, index){ %>
    <tr>
        <td class="col-sm-1"><%= index + 1 %></td>
        <td class="col-sm-5" id="goodsName" data-toggle="tooltip"
            title="<%= item.name %>"><%= item.name %></td>
        <td class="col-sm-1"><%= item.price %></td>
        <td class="col-sm-2"><%= item.createdAt %></td>
        <td class="col-sm-2"><%= item.updatedAt %></td>
        <td class="col-sm-1" id="data-<%= index %>">
            <% item.info.forEach(function(item, index){ %>
            <input type="text" class="hide" value="<%= item.count + ',' + item.size %>"/>
            <% }) %>
            <a href="#myModal" data-toggle="modal"
               onclick="editGoods('<%= item._id %>','<%= item.name %>','<%= item.price %>','<%= index %>','<%= item.describe %>','<%= item.image %>')">编辑</a>
            <a href="javascript:delGoods('<%= item._id %>')">删除</a>
        </td>
    </tr>
    <% }) %>
    </tbody>
</table>
<div class="pull-right">
    <ul class="pager">
        <li><a href="/goods/getShopkeeperGoods?page=<%= parseInt(page) - 1 %>"
               style="visibility: <%= parseInt(page) > 1 ? '' : 'hidden' %>">上一页</a></li>
        <li><span><%= page + '/' + total %></span></li>
        <li><input type="text" class="page" onblur="search('1','<%= total %>',this)"/></li>
        <li><a href="/goods/getShopkeeperGoods?page=<%= parseInt(page) + 1 %>"
               style="visibility: <%= parseInt(page) < total ? '' : 'hidden' %>">下一页</a></li>
    </ul>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-content">
                <div style="padding: 40px 40px 60px 0;">
                    <%- include('goods_info') %>
                </div>
            </div>
        </div>
    </div>

</div>


<script src="/javascripts/goods.js"></script>
<%- include('common/footer_back.ejs') %>